package com.itita.ww2.handler.requesthandler.building;

import java.sql.SQLException;

import com.smartfoxserver.v2.entities.User;
import com.smartfoxserver.v2.entities.data.ISFSObject;
import com.smartfoxserver.v2.entities.data.SFSObject;
import com.itita.ww2.core.MessageHandler;
import com.itita.ww2.core.WW2Exception;
import com.itita.ww2.game.user.UserService;
import com.itita.ww2.model.user.UserProfile;
import com.itita.ww2.utils.handler.IRequestOper;

/**
 * 收集建筑资源
 * @author NorthLan
 *
 */
public class CollectBDResource implements IRequestOper {

	@Override
	public boolean execute(String requestCMD, User user, ISFSObject params) throws WW2Exception, SQLException {
		UserProfile userProfile = UserService.getInstance().getUserProfile(user);
		int duration = userProfile.getResManager().collectBDResource();
		// 同步
		userProfile.getResManager().sync();
		// 
		ISFSObject backObj = SFSObject.newInstance();
		backObj.putInt("duration", duration);
		MessageHandler.getInstance().sendMsg(requestCMD, backObj, user, null, true);
		return true;
	}
}
